% PM calibration adjustments
% 2014 model

% Corrects top 0.5% of overpredictions and top 0.5% underpredictions
% Method follows Sergi et al. 2019

% PM species: total PM, primary, VOC, NH4, NO3, SO4

% overlay matrices (create tall matrices at bottom)
PM25_Cal = PM25_Cal_base .* ones(3109, 3109); 
VOC_Cal =  VOC_Cal_base .* ones(3109, 3109); 
NH4_Cal =  NH4_Cal_base .* ones(3109, 3109); 
NOx_Cal =  NOx_Cal_base .* ones(3109, 3109); 
SO2_Cal =  SO2_Cal_base .* ones(3109, 3109); 

% over-predictions
PM25_Cal(:, 173) = PM25_Cal(:, 173) .* 1;
VOC_Cal(:, 173) = VOC_Cal(:, 173) .* 1;
NH4_Cal(:, 173) = NH4_Cal(:, 173) .* 0.5;
NOx_Cal(:, 173) = NOx_Cal(:, 173) .* 0.5;
SO2_Cal(:, 173) =  SO2_Cal(:, 173) .* 1; 

PM25_Cal(:, 176) = PM25_Cal(:, 176) .* 0.5;
NH4_Cal(:, 176) = NH4_Cal(:, 176) .* 0.5;
NOx_Cal(:, 176) = NOx_Cal(:, 176) .* 0.3;
SO2_Cal(:, 176) = SO2_Cal(:, 176) .* 0.3;
VOC_Cal(:, 176) = VOC_Cal(:, 176) .* 0.3;

PM25_Cal(:, 181) = PM25_Cal(:, 181) .* 0.3;
NH4_Cal(:, 181) = NH4_Cal(:, 181) .* 0.1;
NOx_Cal(:, 181) = NOx_Cal(:, 181) .* 0.3;
SO2_Cal(:, 181) = SO2_Cal(:, 181) .* 0.3;
VOC_Cal(:, 181) = VOC_Cal(:, 181) .* 0.3;

PM25_Cal(:, 195) = PM25_Cal(:, 195) .* 0.3;
NH4_Cal(:, 195) = NH4_Cal(:, 195) .* 0.1;
NOx_Cal(:, 195) = NOx_Cal(:, 195) .* 0.3;
SO2_Cal(:, 195) = SO2_Cal(:, 195) .* 0.3;
VOC_Cal(:, 195) = VOC_Cal(:, 195) .* 0.3;

PM25_Cal(:, 196) = PM25_Cal(:, 196) .* 0.3;
NH4_Cal(:, 196) = NH4_Cal(:, 196) .* 0.1;
NOx_Cal(:, 196) = NOx_Cal(:, 196) .* 0.3;
SO2_Cal(:, 196) = SO2_Cal(:, 196) .* 0.3;
VOC_Cal(:, 196) = VOC_Cal(:, 196) .* 0.3;

PM25_Cal(:, 205) = PM25_Cal(:, 205) .* 0.3;
NH4_Cal(:, 205) = NH4_Cal(:, 205) .* 0.1;
NOx_Cal(:, 205) = NOx_Cal(:, 205) .* 0.3;
SO2_Cal(:, 205) = SO2_Cal(:, 205) .* 0.3;
VOC_Cal(:, 205) = VOC_Cal(:, 205) .* 0.3;

PM25_Cal(:, 207) = PM25_Cal(:, 207) .* 0.4;
NH4_Cal(:, 207) = NH4_Cal(:, 207) .* 0.25;
NOx_Cal(:, 207) = NOx_Cal(:, 207) .* 0.4;
SO2_Cal(:, 207) = SO2_Cal(:, 207) .* 0.4;
VOC_Cal(:, 207) = VOC_Cal(:, 207) .* 0.4;

PM25_Cal(:, 363) = PM25_Cal(:, 363) .* 0.5;
NH4_Cal(:, 363) = NH4_Cal(:, 363) .* 0.3;
NOx_Cal(:, 363) = NOx_Cal(:, 363) .* 1;
SO2_Cal(:, 363) = SO2_Cal(:, 363) .* 1;
VOC_Cal(:, 363) = VOC_Cal(:, 363) .* 1;

PM25_Cal(:, 582) = PM25_Cal(:, 582) .* 0.3;
NH4_Cal(:, 582) = NH4_Cal(:, 582) .* 0.1;
NOx_Cal(:, 582) = NOx_Cal(:, 582) .* 0.3;
SO2_Cal(:, 582) = SO2_Cal(:, 582) .* 0.3;
VOC_Cal(:, 582) = VOC_Cal(:, 582) .* 0.3;

PM25_Cal(:, 605) = PM25_Cal(:, 605) .* 0.2;
NH4_Cal(:, 605) = NH4_Cal(:, 605) .* 0.2;
NOx_Cal(:, 605) = NOx_Cal(:, 605) .* 0.2;
SO2_Cal(:, 605) = SO2_Cal(:, 605) .* 0.2;
VOC_Cal(:, 605) = VOC_Cal(:, 605) .* 0.2;

PM25_Cal(:, 1081) = PM25_Cal(:, 1081) .* 0.4;
NH4_Cal(:, 1081) = NH4_Cal(:, 1081) .* 0.4;
NOx_Cal(:, 1081) = NOx_Cal(:, 1801) .* 0.4;
SO2_Cal(:, 1081) = SO2_Cal(:, 1081) .* 0.4;
VOC_Cal(:, 1081) = VOC_Cal(:, 1081) .* 0.4;

PM25_Cal(:, 1095) = PM25_Cal(:, 1095) .* 0.5;
VOC_Cal(:, 1095) =  VOC_Cal(:, 1095) .* 0.3; 
NH4_Cal(:, 1095) =  NH4_Cal(:, 1095) .* 0.3; 
NOx_Cal(:, 1095) =  NOx_Cal(:, 1095) .* 0.3; 
SO2_Cal(:, 1095) =  SO2_Cal(:, 1095) .* 0.3;

PM25_Cal(:, 1125) = PM25_Cal(:, 1125) .* 0.4;
NH4_Cal(:, 1125) = NH4_Cal(:, 1125) .* 0.4;
NOx_Cal(:, 1125) = NOx_Cal(:, 1125) .* 0.4;
SO2_Cal(:, 1125) = SO2_Cal(:, 1125) .* 0.4;
VOC_Cal(:, 1125) = VOC_Cal(:, 1125) .* 0.4;

PM25_Cal(:, 1139) = PM25_Cal(:, 1139) .* 0.75;
VOC_Cal(:, 1139) =  VOC_Cal(:, 1139) .* 0.3; 
NH4_Cal(:, 1139) =  NH4_Cal(:, 1139) .* 0.3; 
NOx_Cal(:, 1139) =  NOx_Cal(:, 1139) .* 0.3; 
SO2_Cal(:, 1139) =  SO2_Cal(:, 1139) .* 0.3;

PM25_Cal(:, 1289) = PM25_Cal(:, 1289) .* 0.3;
NH4_Cal(:, 1289) = NH4_Cal(:, 1289) .* 0.1;
NOx_Cal(:, 1289) = NOx_Cal(:, 1289) .* 0.3;
SO2_Cal(:, 1289) = SO2_Cal(:, 1289) .* 0.3;
VOC_Cal(:, 1289) = VOC_Cal(:, 1289) .* 0.3;

PM25_Cal(:, 1341) = PM25_Cal(:, 1341) .* 0.2;
VOC_Cal(:, 1341) =  VOC_Cal(:, 1341) .* 0.1; 
NH4_Cal(:, 1341) =  NH4_Cal(:, 1341) .* 0.2; 
NOx_Cal(:, 1341) =  NOx_Cal(:, 1341) .* 0.2; 
SO2_Cal(:, 1341) =  SO2_Cal(:, 1341) .* 0.2;

PM25_Cal(:, 1361) = PM25_Cal(:, 1361) .* 0.25;
VOC_Cal(:, 1361) =  VOC_Cal(:, 1361) .* 0.25; 
NH4_Cal(:, 1361) =  NH4_Cal(:, 1361) .* 0.25; 
NOx_Cal(:, 1361) =  NOx_Cal(:, 1361) .* 0.25; 
SO2_Cal(:, 1361) =  SO2_Cal(:, 1361) .* 0.25;

PM25_Cal(:, 1796) = PM25_Cal(:, 1796) .* 0.3;
NH4_Cal(:, 1796) = NH4_Cal(:, 1796) .* 0.1;
NOx_Cal(:, 1796) = NOx_Cal(:, 1796) .* 0.3;
SO2_Cal(:, 1796) = SO2_Cal(:, 1796) .* 0.3;
VOC_Cal(:, 1796) = VOC_Cal(:, 1796) .* 0.3;

PM25_Cal(:, 1824) = PM25_Cal(:, 1824) .* 0.3;
NH4_Cal(:, 1824) = NH4_Cal(:, 1824) .* 0.1;
NOx_Cal(:, 1824) = NOx_Cal(:, 1824) .* 0.3;
SO2_Cal(:, 1824) = SO2_Cal(:, 1824) .* 0.3;
VOC_Cal(:, 1824) = VOC_Cal(:, 1824) .* 0.3;

PM25_Cal(:, 1834) = PM25_Cal(:, 1834) .* 0.3;
NH4_Cal(:, 1834) = NH4_Cal(:, 1834) .* 0.1;
NOx_Cal(:, 1834) = NOx_Cal(:, 1834) .* 0.3;
SO2_Cal(:, 1834) = SO2_Cal(:, 1834) .* 0.3;
VOC_Cal(:, 1834) = VOC_Cal(:, 1834) .* 0.3;

PM25_Cal(:, 1864) = PM25_Cal(:, 1864) .* 0.3;
VOC_Cal(:, 1864) =  VOC_Cal(:, 1864) .* 0.3; 
NH4_Cal(:, 1864) =  NH4_Cal(:, 1864) .* 0.3; 
NOx_Cal(:, 1864) =  NOx_Cal(:, 1864) .* 0.3; 
SO2_Cal(:, 1864) =  SO2_Cal(:, 1864) .* 0.3;

PM25_Cal(:, 1881) = PM25_Cal(:, 1881) .* 0.3;
VOC_Cal(:, 1881) =  VOC_Cal(:, 1881) .* 0.3; 
NH4_Cal(:, 1881) =  NH4_Cal(:, 1881) .* 0.3; 
NOx_Cal(:, 1881) =  NOx_Cal(:, 1881) .* 0.3; 
SO2_Cal(:, 1881) =  SO2_Cal(:, 1881) .* 0.3;

PM25_Cal(:, 1886) = PM25_Cal(:, 1886) .* 0.3;
VOC_Cal(:, 1886) =  VOC_Cal(:, 1886) .* 0.3; 
NH4_Cal(:, 1886) =  NH4_Cal(:, 1886) .* 0.3; 
NOx_Cal(:, 1886) =  NOx_Cal(:, 1886) .* 0.3; 
SO2_Cal(:, 1886) =  SO2_Cal(:, 1886) .* 0.3;

PM25_Cal(:, 1937) = PM25_Cal(:, 1937) .* 0.4;
VOC_Cal(:, 1937) =  VOC_Cal(:, 1937) .* 0.4; 
NH4_Cal(:, 1937) =  NH4_Cal(:, 1937) .* 0.4; 
NOx_Cal(:, 1937) =  NOx_Cal(:, 1937) .* 0.4; 
SO2_Cal(:, 1937) =  SO2_Cal(:, 1937) .* 0.4;

PM25_Cal(:, 2063) = PM25_Cal(:, 2063) .* 0.4;
VOC_Cal(:, 2063) =  VOC_Cal(:, 2063) .* 0.4; 
NH4_Cal(:, 2063) =  NH4_Cal(:, 2063) .* 0.4; 
NOx_Cal(:, 2063) =  NOx_Cal(:, 2063) .* 0.4; 
SO2_Cal(:, 2063) =  SO2_Cal(:, 2063) .* 0.4;

PM25_Cal(:, 2760) = PM25_Cal(:, 2760) .* 0.4;
NH4_Cal(:, 2760) = NH4_Cal(:, 2760) .* 0.1;
NOx_Cal(:, 2760) = NOx_Cal(:, 2760) .* 0.1;
SO2_Cal(:, 2760) = SO2_Cal(:, 2760) .* 0.4;
VOC_Cal(:, 2760) = VOC_Cal(:, 2760) .* 0.4;

PM25_Cal(:, 2792) = PM25_Cal(:, 2792) .* 0.4;
NH4_Cal(:, 2792) = NH4_Cal(:, 2792) .* 0.1;
NOx_Cal(:, 2792) = NOx_Cal(:, 2792) .* 0.1;
SO2_Cal(:, 2792) = SO2_Cal(:, 2792) .* 0.4;
VOC_Cal(:, 2792) = VOC_Cal(:, 2792) .* 0.4;

% under-predictions
PM25_Cal(:, 161) = PM25_Cal(:, 161) .* 3; 
VOC_Cal(:, 161) =  VOC_Cal(:, 161) .* 3; 
NH4_Cal(:, 161) =  NH4_Cal(:, 161) .* 3; 
NOx_Cal(:, 161) =  NOx_Cal(:, 161) .* 3; 
SO2_Cal(:, 161) =  SO2_Cal(:, 161) .* 3; 

PM25_Cal(:, 168) = PM25_Cal(:, 168) .* 2.5; 
VOC_Cal(:, 168) =  VOC_Cal(:, 168) .* 2.5; 
NH4_Cal(:, 168) =  NH4_Cal(:, 168) .* 2.5; 
NOx_Cal(:, 168) =  NOx_Cal(:, 168) .* 2.5; 
SO2_Cal(:, 168) =  SO2_Cal(:, 168) .* 2.5; 

PM25_Cal(:, 172) = PM25_Cal(:, 172) .* 5;
VOC_Cal(:, 172) = VOC_Cal(:, 172) .* 3;
NH4_Cal(:, 172) = NH4_Cal(:, 172) .* 3.5;
NOx_Cal(:, 172) = NOx_Cal(:, 172) .* 1;
SO2_Cal(:, 172) =  SO2_Cal(:, 172) .* 3; 

PM25_Cal(:, 175) = PM25_Cal(:, 175) .* 5; 
VOC_Cal(:, 175) =  VOC_Cal(:, 175) .* 3; 
NH4_Cal(:, 175) =  NH4_Cal(:, 175) .* 2; 
NOx_Cal(:, 175) =  NOx_Cal(:, 175) .* 3; 
SO2_Cal(:, 175) =  SO2_Cal(:, 175) .* 3; 

PM25_Cal(:, 189) = PM25_Cal(:, 189) .* 4; 
VOC_Cal(:, 189) =  VOC_Cal(:, 189) .* 4; 
NH4_Cal(:, 189) =  NH4_Cal(:, 189) .* 4; 
NOx_Cal(:, 189) =  NOx_Cal(:, 189) .* 4; 
SO2_Cal(:, 189) =  SO2_Cal(:, 189) .* 4; 

PM25_Cal(:, 202) = PM25_Cal(:, 202) .* 4; 
VOC_Cal(:, 202) =  VOC_Cal(:, 202) .* 3; 
NH4_Cal(:, 202) =  NH4_Cal(:, 202) .* 3; 
NOx_Cal(:, 202) =  NOx_Cal(:, 202) .* 3; 
SO2_Cal(:, 202) =  SO2_Cal(:, 202) .* 3; 

PM25_Cal(:, 209) = PM25_Cal(:, 209) .* 5; 
VOC_Cal(:, 209) =  VOC_Cal(:, 209) .* 3; 
NH4_Cal(:, 209) =  NH4_Cal(:, 209) .* 3; 
NOx_Cal(:, 209) =  NOx_Cal(:, 209) .* 3; 
SO2_Cal(:, 209) =  SO2_Cal(:, 209) .* 3;

PM25_Cal(:, 546) = PM25_Cal(:, 546) .*5;
VOC_Cal(:, 546) = VOC_Cal(:, 546) .* 5;
NH4_Cal(:, 546) = NH4_Cal(:, 546) .* 7;
NOx_Cal(:, 546) = NOx_Cal(:, 546) .* 4;
SO2_Cal(:, 546) =  SO2_Cal(:, 546) .* 4;

PM25_Cal(:, 1727) = PM25_Cal(:, 1727) .* 6; 
VOC_Cal(:, 1727) =  VOC_Cal(:, 1727) .* 4; 
NH4_Cal(:, 1727) =  NH4_Cal(:, 1727) .* 4; 
NOx_Cal(:, 1727) =  NOx_Cal(:, 1727) .* 4; 
SO2_Cal(:, 1727) =  SO2_Cal(:, 1727) .* 4; 

PM25_Cal(:, 2180) = PM25_Cal(:, 2180) .* 5; 
VOC_Cal(:, 2180) =  VOC_Cal(:, 2180) .* 5; 
NH4_Cal(:, 2180) =  NH4_Cal(:, 2180) .* 5; 
NOx_Cal(:, 2180) =  NOx_Cal(:, 2180) .* 5; 
SO2_Cal(:, 2180) =  SO2_Cal(:, 2180) .* 5;

PM25_Cal(:, 2186) = PM25_Cal(:, 2186) .* 6; 
VOC_Cal(:, 2186) =  VOC_Cal(:, 2186) .* 6; 
NH4_Cal(:, 2186) =  NH4_Cal(:, 2186) .* 8; 
NOx_Cal(:, 2186) =  NOx_Cal(:, 2186) .* 4; 
SO2_Cal(:, 2186) =  SO2_Cal(:, 2186) .* 4;

PM25_Cal(:, 2188) = PM25_Cal(:, 2188) .* 3; 
VOC_Cal(:, 2188) =  VOC_Cal(:, 2188) .* 3; 
NH4_Cal(:, 2188) =  NH4_Cal(:, 2188) .* 3; 
NOx_Cal(:, 2188) =  NOx_Cal(:, 2188) .* 3; 
SO2_Cal(:, 2188) =  SO2_Cal(:, 2188) .* 3;

PM25_Cal(:, 2191) = PM25_Cal(:, 2191) .* 6; 
VOC_Cal(:, 2191) =  VOC_Cal(:, 2191) .* 6; 
NH4_Cal(:, 2191) =  NH4_Cal(:, 2191) .* 6; 
NOx_Cal(:, 2191) =  NOx_Cal(:, 2191) .* 6; 
SO2_Cal(:, 2191) =  SO2_Cal(:, 2191) .* 5;

PM25_Cal(:, 2512) = PM25_Cal(:, 2512) .* 6; 
VOC_Cal(:, 2512) =  VOC_Cal(:, 2512) .* 4; 
NH4_Cal(:, 2512) =  NH4_Cal(:, 2512) .* 4; 
NOx_Cal(:, 2512) =  NOx_Cal(:, 2512) .* 4; 
SO2_Cal(:, 2512) =  SO2_Cal(:, 2512) .* 4;

PM25_Cal(:, 2519) = PM25_Cal(:, 2519) .* 4; 
VOC_Cal(:, 2519) =  VOC_Cal(:, 2519) .* 2; 
NH4_Cal(:, 2519) =  NH4_Cal(:, 2519) .* 2; 
NOx_Cal(:, 2519) =  NOx_Cal(:, 2519) .* 2; 
SO2_Cal(:, 2519) =  SO2_Cal(:, 2519) .* 2;

PM25_Cal(:, 2554) = PM25_Cal(:, 2554) .* 4; 
VOC_Cal(:, 2554) =  VOC_Cal(:, 2554) .* 4; 
NH4_Cal(:, 2554) =  NH4_Cal(:, 2554) .* 4; 
NOx_Cal(:, 2554) =  NOx_Cal(:, 2554) .* 4; 
SO2_Cal(:, 2554) =  SO2_Cal(:, 2554) .* 3;

PM25_Cal(:, 2596) = PM25_Cal(:, 2596) .* 3; 
VOC_Cal(:, 2596) =  VOC_Cal(:, 2596) .* 3; 
NH4_Cal(:, 2596) =  NH4_Cal(:, 2596) .* 3; 
NOx_Cal(:, 2596) =  NOx_Cal(:, 2596) .* 3; 
SO2_Cal(:, 2596) =  SO2_Cal(:, 2596) .* 3;

PM25_Cal(:, 2603) = PM25_Cal(:, 2603) .* 4; 
VOC_Cal(:, 2603) =  VOC_Cal(:, 2603) .* 4; 
NH4_Cal(:, 2603) =  NH4_Cal(:, 2603) .* 6; 
NOx_Cal(:, 2603) =  NOx_Cal(:, 2603) .* 4; 
SO2_Cal(:, 2603) =  SO2_Cal(:, 2603) .* 4;

PM25_Cal(:, 2610) = PM25_Cal(:, 2610) .* 4; 
VOC_Cal(:, 2610) =  VOC_Cal(:, 2610) .* 2; 
NH4_Cal(:, 2610) =  NH4_Cal(:, 2610) .* 5; 
NOx_Cal(:, 2610) =  NOx_Cal(:, 2610) .* 5; 
SO2_Cal(:, 2610) =  SO2_Cal(:, 2610) .* 5;

PM25_Cal(:, 2612) = PM25_Cal(:, 2612) .* 4; 
VOC_Cal(:, 2612) =  VOC_Cal(:, 2612) .* 4; 
NH4_Cal(:, 2612) =  NH4_Cal(:, 2612) .* 6; 
NOx_Cal(:, 2612) =  NOx_Cal(:, 2612) .* 4; 
SO2_Cal(:, 2612) =  SO2_Cal(:, 2612) .* 4;

PM25_Cal(:, 2619) = PM25_Cal(:, 2619) .* 3; 
VOC_Cal(:, 2619) =  VOC_Cal(:, 2619) .* 3; 
NH4_Cal(:, 2619) =  NH4_Cal(:, 2619) .* 4; 
NOx_Cal(:, 2619) =  NOx_Cal(:, 2619) .* 4; 
SO2_Cal(:, 2619) =  SO2_Cal(:, 2619) .* 4;

PM25_Cal(:, 2650) = PM25_Cal(:, 2650) .* 5; 
VOC_Cal(:, 2650) =  VOC_Cal(:, 2650) .* 4; 
NH4_Cal(:, 2650) =  NH4_Cal(:, 2650) .* 4; 
NOx_Cal(:, 2650) =  NOx_Cal(:, 2650) .* 4; 
SO2_Cal(:, 2650) =  SO2_Cal(:, 2650) .* 4;

PM25_Cal(:, 2677) = PM25_Cal(:, 2677) .* 4; 
VOC_Cal(:, 2677) =  VOC_Cal(:, 2677) .* 4; 
NH4_Cal(:, 2677) =  NH4_Cal(:, 2677) .* 6; 
NOx_Cal(:, 2677) =  NOx_Cal(:, 2677) .* 4; 
SO2_Cal(:, 2677) =  SO2_Cal(:, 2677) .* 4;

PM25_Cal(:, 2684) = PM25_Cal(:, 2684) .* 3; 
VOC_Cal(:, 2684) =  VOC_Cal(:, 2684) .* 3; 
NH4_Cal(:, 2684) =  NH4_Cal(:, 2684) .* 5; 
NOx_Cal(:, 2684) =  NOx_Cal(:, 2684) .* 5; 
SO2_Cal(:, 2684) =  SO2_Cal(:, 2684) .* 5;

PM25_Cal(:, 2721) = PM25_Cal(:, 2721) .* 5; 
VOC_Cal(:, 2721) =  VOC_Cal(:, 2721) .* 2; 
NH4_Cal(:, 2721) =  NH4_Cal(:, 2721) .* 5; 
NOx_Cal(:, 2721) =  NOx_Cal(:, 2721) .* 5; 
SO2_Cal(:, 2721) =  SO2_Cal(:, 2721) .* 5;

PM25_Cal(:, 2728) = PM25_Cal(:, 2728) .* 6; 
VOC_Cal(:, 2728) =  VOC_Cal(:, 2728) .* 5; 
NH4_Cal(:, 2728) =  NH4_Cal(:, 2728) .* 5; 
NOx_Cal(:, 2728) =  NOx_Cal(:, 2728) .* 5; 
SO2_Cal(:, 2728) =  SO2_Cal(:, 2728) .* 5;

% tall calibrations
PM25_Cal_tall = PM25_Cal(1:565, :); 
VOC_Cal_tall =  VOC_Cal(1:565, :);  
NH4_Cal_tall =  NH4_Cal(1:565, :);  
NOx_Cal_tall =  NOx_Cal(1:565, :); 
SO2_Cal_tall =  SO2_Cal(1:565, :);  

PM25_Cal_tall2 = PM25_Cal(1:91, :); 
VOC_Cal_tall2 =  VOC_Cal(1:91, :);  
NH4_Cal_tall2 =  NH4_Cal(1:91, :);  
NOx_Cal_tall2 =  NOx_Cal(1:91, :); 
SO2_Cal_tall2 =  SO2_Cal(1:91, :);  
